package com.coupons.business.category.controller;

import java.util.Date;
import java.util.Iterator;
import java.util.List;

import com.coupons.business.common.context.manager.CouponCommonAppContextManager;
import com.coupons.business.common.exception.BaseCouponsAppException;
import com.coupons.business.common.vo.Category;
import com.coupons.business.category.controller.ICategoryManager;
import com.coupons.business.category.service.CategoryManagerService;

import junit.framework.TestCase;

public class CategoryManagerTest extends TestCase {

	ICategoryManager manager;
	
	protected void setUp() throws Exception {
		super.setUp();
		manager = (CategoryManagerService)CouponCommonAppContextManager.
		getInstance().getBeanByName("categoryManagerService");
	}
	
	public void testCreateCategory()
	{
		try {
			Category objlCategory = new Category();
			objlCategory.setCategoryName("bag");
			objlCategory.setDescription("first category");
			objlCategory.setPartnerId(100);
			objlCategory.setMerchantId(121);
			objlCategory.setDescription("Abc stores from New York");
			objlCategory.setStatus("Active");
			objlCategory.setRank(1);
			objlCategory.setLastUpdatedUser("bvn");
			manager.createCategory(objlCategory);
			System.out.println("Category Created: "+objlCategory);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void testUpdateCategory()
	{
		try {
			Category objlCategory = new Category();
			objlCategory.setCategoryId(121);
			objlCategory.setCategoryName("Abc Stores");
			objlCategory.setDescription("first category");
			objlCategory.setPartnerId(100);
			objlCategory.setDescription("Abc stores from New York");
			objlCategory.setStatus("Active");
			objlCategory.setRank(1);			
			objlCategory.setLastUpdatedUser("bvn");
			manager.updateCategory(objlCategory);
			System.out.println("Category Updated: "+objlCategory);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void testGetCategory()
	{		
		try {
			Category objlCategory = manager.getCategory(123);
			System.out.println(objlCategory);
		} catch (BaseCouponsAppException e) {			
			e.printStackTrace();
		}
	}
	
	public void testGetAllCategorys()
	{		
		try {
			List<Category> categorys = manager.getAllCategorys(100,260);
			for (Iterator iterator = categorys.iterator(); iterator.hasNext();) {
				Category category = (Category) iterator.next();
				System.out.println(category);
			}
		} catch (BaseCouponsAppException e) {			
			e.printStackTrace();
		}
	}
}
